/*滚动效果*/
function ppRoll(a) {
    this.myA = a;
    this.myA.IsPlay = 1;
    this.$(a.demo).style.overflow = "hidden";
    this.$(a.demo).style.width = a.width;
    this.$(a.demo).style.height = a.height;
    this.$(a.demo2).innerHTML = this.$(a.demo1).innerHTML;
    this.$(a.demo).scrollTop = this.$(a.demo).scrollHeight;
    this.Marquee();
    this.$(a.demo).onmouseover = function() {
        eval(a.objStr + ".clearIntervalpp();");
    }
    this.$(a.demo).onmouseout = function() {
        eval(a.objStr + ".setTimeoutpp();");
    }
}
ppRoll.prototype.$ = function(Id) {
    return document.getElementById(Id);
}
ppRoll.prototype.getV = function() {
    alert(this.$(this.myA.demo2).offsetWidth - this.$(this.myA.demo).scrollLeft);
    alert(this.$(this.myA.demo2).offsetWidth);
    alert(this.$(this.myA.demo).scrollLeft);
}
ppRoll.prototype.Marquee = function() {
    this.MyMar = setTimeout(this.myA.objStr + ".Marquee();", this.myA.speed);
    if (this.myA.IsPlay == 1) {
        if (this.myA.direction == "top") {
            if (this.$(this.myA.demo).scrollTop >= this.$(this.myA.demo2).offsetHeight) this.$(this.myA.demo).scrollTop -= this.$(this.myA.demo2).offsetHeight;
            else {
                this.$(this.myA.demo).scrollTop++;
            }
        }
        if (this.myA.direction == "down") {
            if (this.$(this.myA.demo1).offsetTop - this.$(this.myA.demo).scrollTop >= 0) this.$(this.myA.demo).scrollTop += this.$(this.myA.demo2).offsetHeight;
            else {
                this.$(this.myA.demo).scrollTop--;
            }
        }
        if (this.myA.direction == "left") {
            if (this.$(this.myA.demo2).offsetWidth - this.$(this.myA.demo).scrollLeft <= 0) this.$(this.myA.demo).scrollLeft -= this.$(this.myA.demo1).offsetWidth;
            else {
                this.$(this.myA.demo).scrollLeft++;
            }
        }
        if (this.myA.direction == "right") {
            if (this.$(this.myA.demo).scrollLeft <= 0) this.$(this.myA.demo).scrollLeft += this.$(this.myA.demo2).offsetWidth;
            else {
                this.$(this.myA.demo).scrollLeft--;
            }
        }

    }
}
ppRoll.prototype.clearIntervalpp = function() {
    this.myA.IsPlay = 0;
}
ppRoll.prototype.setTimeoutpp = function() {
    this.myA.IsPlay = 1;
}

/*从下拉框中打开网站*/
function openSelectLink(obj){
	var val=obj.options[obj.selectedIndex].value;
	if(val=='0') return;
	obj.options[0].selected=true;
	window.open(val,"_blank");
}

//高亮
function hightlight(node,words){
	var len=words.length;
	this._hl=function(textNode){
		var data=textNode.data.toUpperCase();
		for(var i=0;i<len;i++){
			var pos=data.indexOf(words[i].toUpperCase());
			if(pos>=0){
				var spannode = document.createElement('span');
				spannode.style.backgroundColor="yellow";
				var middlebit = textNode.splitText(pos);
				var endbit = middlebit.splitText(words[i].length);
				var middleclone = middlebit.cloneNode(true);
				spannode.appendChild(middleclone);
				middlebit.parentNode.replaceChild(spannode, middlebit);
			}
		}
	}
	var skip=0;
	if (node.nodeType == 3) {	//text节点
		this._hl(node, words);
		skip=1;
	}else if (node.nodeType == 1 && node.childNodes && !/(script|style)/i.test(node.tagName)) {		//元素节点
		for (var i = 0; i < node.childNodes.length; ++i) {
			i += hightlight(node.childNodes[i], words);
		}
	}
	return skip;
}

//下拉菜单
function dropmenu(menuid){
	var navigation=document.getElementById(menuid);
	var menus=navigation.getElementsByTagName("li");
	for(var i=0,len=menus.length;i<len;i++){
		var menu=menus[i];
		menu.onmouseover=function(){
			var m=_getSubMenu(this);
			if(m) m.style.display="block";
		}
		menu.onmouseout=function(){
			var m=_getSubMenu(this);
			if(m) m.style.display="none";
		}
	}
}
function _getSubMenu(menu){
	var uls=menu.getElementsByTagName("ul");
    if(uls.length>0){
        var subMenu=uls[0];
        if(subMenu.parentNode!=menu) return false;
        return subMenu;
    }
	return false;
}